Add static_asserts to enforce that py::smart_holder is combined with py::trampoline_self_life_support#5633
Merged
rwgk merged 6 commits intoMay 1, 2025
Conversation
…upport when used in combination with smart_holder
…_support only if used in combination with smart_holder
```
/__w/pybind11/pybind11/tests/test_class_sh_trampoline_basic.cpp:35:46: error: the parameter 'obj' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param,-warnings-as-errors]
35 | int AddInCppSharedPtr(std::shared_ptr<Abase> obj, int other_val) {
| ^
| const &
```
…S_DEFAULT_BUT_NEVER_USE_IN_PRODUCTION_PLEASE is defined.
Contributor
|
This seems like a good idea to me. 👍 |
Collaborator
Author
|
Thanks @virtuald! I'll merge this PR now. Thanks also for the other review. I'll work on changes there asap. (For today my brain is fried...) |
b-pass
pushed a commit
to b-pass/pybind11
that referenced
this pull request
May 9, 2025
…ith `py::trampoline_self_life_support` (pybind#5633) * Strictly enforce: trampoline must inherit from trampoline_self_life_support when used in combination with smart_holder * Simplify test_class_sh_trampoline_basic.cpp,py (only one Abase is needed now) * Replace obsolete sophisticated `throw value_error()` with a simple `assert()` * Strictly enforce: trampoline should inherit from trampoline_self_life_support only if used in combination with smart_holder * Resolve clang-tidy error ``` /__w/pybind11/pybind11/tests/test_class_sh_trampoline_basic.cpp:35:46: error: the parameter 'obj' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param,-warnings-as-errors] 35 | int AddInCppSharedPtr(std::shared_ptr<Abase> obj, int other_val) { | ^ | const & ``` * Disable new static_assert if PYBIND11_RUN_TESTING_WITH_SMART_HOLDER_AS_DEFAULT_BUT_NEVER_USE_IN_PRODUCTION_PLEASE is defined.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Context:
In some long ChatGPT conversation related to PR #5624 rwgk wrote:
ChatGPT said:
A changelog entry is not needed because the smart_holder feature was not released yet.